package com.homwee.factory.tvtool;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import com.homwee.factory.tvtool.AQLayout;
import com.homwee.factory.tvtool.AQService;

import android.util.Log;

public class StaticValues {
	public static boolean bFloatTVtool = false;
	public static String LOGTAG = "TVtool:StaticValues:";
	public static boolean bSaveAQAndExit = false;
	public static boolean bSavePQAndExit = false;
	public static AQLayout aqLayoutInstance;
	public static AQService aqServiceInstance;
//	public static PQLayout pqLayoutInstance;

	
    public final static int CHTV_CONTEXTUAL_MODEL_STANDARD = 0;  //standard
    public final static int CHTV_CONTEXTUAL_MODEL_MOVIE    = 1;  //Theatre
    public final static int CHTV_CONTEXTUAL_MODEL_UMAX     = 2;  //umax
    public final static int CHTV_CONTEXTUAL_MODEL_READING  = 3;  //Read
    public final static int CHTV_CONTEXTUAL_MODEL_MV       = 4;  //mv
    public final static int CHTV_CONTEXTUAL_MODEL_SPORTS   = 5;  //Sports
    public final static int CHTV_CONTEXTUAL_MODEL_GAME     = 6;  //Game
    public final static int CHTV_CONTEXTUAL_MODEL_USER     = 7;  //User-defined
    public final static int CHTV_CONTEXTUAL_MODEL_FOOTBALL = CHTV_CONTEXTUAL_MODEL_USER;
    public final static int CHTV_CONTEXTUAL_MODEL_NUMS     = 8;  //User-defined		
    //AMP TYPE  Power amplifier configuration type
    public final static int CHTV_AMP_IC_5707          = 0;  //5707
    public final static int CHTV_AMP_IC_5711_2CH1     = 1;  //5711
    public final static int CHTV_AMP_IC_5711_2CH      = 2;  //5711
    public final static int CHTV_AMP_IC_5707_AND_5711 = 3;  //5707 ADN 5711  Two types of power amplifiers exist simultaneously, respectively, conversion
    public final static int CHTV_AMP_IC_NULL          = 4;  //No power amplifier, or digital amplifier
    public final static int CHTV_AMP_IC_5711_AND_5711 = 5;  //bi-amp，One for high frequency H，One for low frequency L 
    public final static int CHTV_AMP_IC_5719          = 6;  //5719   MTK5508 new power amplifier type
    public final static int CHTV_AMP_IC_5719_AND_5719 = 7;  //5719  Dual amplifier, a high frequency, a bottom frequency
    public final static int CHTV_AMP_IC_NUMS          = 8;  //NUM Number of power amplifier types
    
    
  //PICTURE SOURCE   Five terminal linear channel overseas channel
    public final static int CHTV_PIC_ATV_PAL     = 0;  
    public final static int CHTV_PIC_ATV_NTSC    = 1;  
    public final static int CHTV_PIC_ATV_SECAM      = 2;  
    public final static int CHTV_PIC_AV_PAL     = 3;  
    public final static int CHTV_PIC_AV_NTSC     = 4;  
    public final static int CHTV_PIC_AV_SECAM      = 5;  
    public final static int CHTV_PIC_YPBPR_SD_I     = 6;  
    public final static int CHTV_PIC_YPBPR_SD_P    = 7;  
    public final static int CHTV_PIC_YPBPR_720P    = 8;  
    public final static int CHTV_PIC_YPBPR_1080I50     = 9;  
    public final static int CHTV_PIC_YPBPR_1080I60     = 10;  
    public final static int CHTV_PIC_YPBPR_1080P     = 11;
    public final static int CHTV_PIC_HDMI_SD_I   = 12; 
    public final static int CHTV_PIC_HDMI_SD_P    = 13; 
    public final static int CHTV_PIC_HDMI_720P      = 14;
    public final static int CHTV_PIC_HDMI_1080I50      = 15;
    public final static int CHTV_PIC_HDMI_1080I60      = 16;
    public final static int CHTV_PIC_HDMI_1080P     = 17;
    public final static int CHTV_PIC_HDMI_UD      = 18;
    public final static int CHTV_PIC_HDMI_VESA      = 19;
    public final static int CHTV_PIC_HDMI_HDR      = 20;
    public final static int CHTV_PIC_VGA     = 21;
    public final static int CHTV_PIC_DTV_SD         = 22;
    public final static int CHTV_PIC_DTV_HD          = 23;
    public final static int CHTV_PIC_DTV_UD    = 24;
    public final static int CHTV_PIC_MMP_SD   	 = 25;
    public final static int CHTV_PIC_MMP_HD   = 26;//=CHTV_PIC_M_FHD
    public final static int CHTV_PIC_MMP_UD    = 27;//=CHTV_PIC_M_UD
    public final static int CHTV_PIC_MMP_HDR   = 28;
    public final static int CHTV_PIC_NET_SD   = 29;  
    public final static int CHTV_PIC_NET_HD   = 30;   
    public final static int CHTV_PIC_NET_UD   = 31;
    public final static int CHTV_PIC_NET_HDR   = 32;    
    public final static int CHTV_PIC_3D   = 33;    
    public final static int CHTV_PIC_UMAX_FHD   = 34;    
    public final static int CHTV_PIC_UMAX_UD   = 35;    
    public final static int CHTV_PIC_M_FHD   = 36;    
    public final static int CHTV_PIC_M_UD   = 37;    
    public final static int CHTV_PIC_RESERVED1   = 38;    
    public final static int CHTV_PIC_RESERVED2   = 39;   
     
    
    
    
//  //PICTURE SOURCE   五端线性通道
//    public final static int CHTV_PIC_ATV_PAL     = 0;  
//    public final static int CHTV_PIC_ATV_NTSC    = 1;  
//    public final static int CHTV_PIC_DTV_SD      = 2;  
//    public final static int CHTV_PIC_DTV_HD      = 3;  
//    public final static int CHTV_PIC_DTV_UD      = 4;  
//    public final static int CHTV_PIC_AV_PAL      = 5;  
//    public final static int CHTV_PIC_AV_NTSC     = 6;  
//    public final static int CHTV_PIC_YPBYR_SD    = 7;  
//    public final static int CHTV_PIC_YPBYR_HD    = 8;  
//    public final static int CHTV_PIC_HDMI_SD     = 9;  
//    public final static int CHTV_PIC_HDMI_HD     = 10;  
//    public final static int CHTV_PIC_HDMI_UD     = 11;
//    public final static int CHTV_PIC_HDMI_VESA   = 12; 
//    public final static int CHTV_PIC_HDMI_HDR    = 13; 
//    public final static int CHTV_PIC_USB_SD      = 14;
//    public final static int CHTV_PIC_USB_HD      = 15;
//    public final static int CHTV_PIC_USB_UD      = 16;
//    public final static int CHTV_PIC_USB_HDR     = 17;
//    public final static int CHTV_PIC_NET_SD      = 18;
//    public final static int CHTV_PIC_NET_HD      = 19;
//    public final static int CHTV_PIC_NET_UD      = 20;
//    public final static int CHTV_PIC_NET_HDR     = 21;
//    public final static int CHTV_PIC_VGA         = 22;
//    public final static int CHTV_PIC_3D          = 23;
//    public final static int CHTV_PIC_UMAX_FHD    = 24;
//    public final static int CHTV_PIC_UMAX_UD   	 = 25;
//    public final static int CHTV_PIC_CHILD_FHD   = 26;//=CHTV_PIC_M_FHD
//    public final static int CHTV_PIC_CHILD_UD    = 27;//=CHTV_PIC_M_UD
//    public final static int CHTV_PIC_RESERVED1   = 28;
//    public final static int CHTV_PIC_RESERVED2   = 29;
    
    //CHANNEL SOURCE   Color temperature channel
    public final static int CHTV_SRC_ATV        = 0;  
    public final static int CHTV_SRC_DTV        = 1;  
    public final static int CHTV_SRC_AV         = 2;  
    public final static int CHTV_SRC_YPBPR      = 3;  
    public final static int CHTV_SRC_HDMI       = 4;  
    public final static int CHTV_SRC_VGA        = 5;  
    public final static int CHTV_SRC_MMP        = 6;  
    
    public final static int CHTV_SRC_NET        = 7;  
	

	
	public static boolean fileCopy(File srcFile, File desFile, boolean reWrite) {

		if (!srcFile.exists()) {
			Log.v(LOGTAG, "fileCopy() : srcFile doesn't existes!");
			return false;
		}

		if (!srcFile.isFile()) {
			Log.v(LOGTAG, "fileCopy() : srcFile is not a file!");
			return false;
		}

		if (!srcFile.canRead()) {
			Log.v(LOGTAG, "fileCopy() : srcFile cannot read!");
			return false;
		}

		if (!desFile.getParentFile().exists()) {
			Log.v(LOGTAG, "fileCopy() : desFile parent wrong");
			return false;
		}

		if (desFile.exists()) {
			Log.v(LOGTAG, "fileCopy() : desFile existes");
			if (reWrite) {
				if (desFile.delete()) {
					Log.v(LOGTAG, "fileCopy() : delete DesFile success");
				} else {
					Log.v(LOGTAG, "fileCopy() : delete DesFile failure");
					return false;
				}
			} else {
				Log.v(LOGTAG,
						"fileCopy() : desFile has already existes,and reWrite is FALSE");
				return false;
			}
		} else {
			Log.v(LOGTAG, "fileCopy() : desFile doesn't existes");
		}

		try 
		{
			FileInputStream srcStream = new FileInputStream(srcFile);
			FileOutputStream desStream = new FileOutputStream(desFile);
			int count;
			byte buffer[] = new byte[1024];

			try 
			{
				while ((count = srcStream.read(buffer)) > 0) 
				{
					desStream.write(buffer, 0, count);
				}
				srcStream.close();
				desStream.close();
			} 
			catch (IOException e) 
			{

				e.printStackTrace();
				return false;
			}

		} 
		catch (FileNotFoundException e) 
		{
			e.printStackTrace();
			return false;
		}
		return true;
	}
}
